import { ActiveTab, BottomPanelVisibility, SelectMode, SelectModel, SortMode, SortModel } from "common.slint";
import { Translations } from "translations.slint";

// State Gui state that shows the current state of the GUI
// It extends Settings global state with settings that are not saved to the settings file
export global GuiState {
    in-out property <length> app_width;
    in-out property <length> app_height;

    in-out property <string> info_text: "Nothing to report";
    in-out property <bool> preview_visible;
    in-out property <image> preview_image;
    in-out property <string> preview_image_path;

    in-out property <length> left_panel_width: 120px;

    in-out property <float> maximum_threads: 40;

    in-out property <bool> choosing_include_directories;
    in-out property <bool> visible_tool_settings;

    in-out property <bool> available_subsettings: active_tab == ActiveTab.SimilarImages || active_tab == ActiveTab.DuplicateFiles || active_tab == ActiveTab.SimilarVideos || active_tab == ActiveTab.SimilarMusic || active_tab == ActiveTab.BigFiles || active_tab == ActiveTab.BrokenFiles;
    in-out property <ActiveTab> active_tab: ActiveTab.DuplicateFiles;
    in-out property <bool> is_tool_tab_active: active_tab != ActiveTab.Settings && active_tab != ActiveTab.About;

    in-out property <[SelectModel]> select_results_list: [
        { data: SelectMode.SelectAll, name: Translations.selection_all_text },
        { data: SelectMode.UnselectAll, name: Translations.selection_deselect_all_text },
    ];

    in-out property <[SortModel]> sort_results_list: [
        { data: SortMode.ItemName, name: Translations.sort_by_item_name_text },
        { data: SortMode.ParentName, name: Translations.sort_by_parent_name_text },
        { data: SortMode.FullName, name: Translations.sort_by_full_name_text },
        { data: SortMode.Size, name: Translations.sort_by_size_text },
        { data: SortMode.ModificationDate, name: Translations.sort_by_modification_date_text },
        { data: SortMode.Selection, name: Translations.sort_by_selection_text },
        { data: SortMode.Checked, name: Translations.sort_by_checked_text },
        { data: SortMode.Reverse, name: Translations.sort_reverse_text },
    ];

    in-out property <[{name: string, tab: ActiveTab}]> tools_model: [
        { name: Translations.tool_duplicate_files_text, tab: ActiveTab.DuplicateFiles },
        { name: Translations.tool_empty_folders_text, tab: ActiveTab.EmptyFolders },
        { name: Translations.tool_big_files_text, tab: ActiveTab.BigFiles },
        { name: Translations.tool_empty_files_text, tab: ActiveTab.EmptyFiles },
        { name: Translations.tool_temporary_files_text, tab: ActiveTab.TemporaryFiles },
        { name: Translations.tool_similar_images_text, tab: ActiveTab.SimilarImages },
        { name: Translations.tool_similar_videos_text, tab: ActiveTab.SimilarVideos },
        { name: Translations.tool_music_duplicates_text, tab: ActiveTab.SimilarMusic },
        { name: Translations.tool_invalid_symlinks_text, tab: ActiveTab.InvalidSymlinks },
        { name: Translations.tool_broken_files_text, tab: ActiveTab.BrokenFiles },
        { name: Translations.tool_bad_extensions_text, tab: ActiveTab.BadExtensions }
    ];

    in-out property <BottomPanelVisibility> bottom_panel_visibility: BottomPanelVisibility.Directories;

    // Bad workaround for missing i64 support in Slint:
    in-out property <int> selected_results_duplicates: 0;
    in-out property <int> selected_results_duplicates2: 0;
    in-out property <int> selected_results_similar_images: 0;
    in-out property <int> selected_results_similar_images2: 0;
    in-out property <int> selected_results_similar_videos: 0;
    in-out property <int> selected_results_similar_videos2: 0;
    in-out property <int> selected_results_similar_music: 0;
    in-out property <int> selected_results_similar_music2: 0;
    in-out property <int> selected_results_big_files: 0;
    in-out property <int> selected_results_big_files2: 0;
    in-out property <int> selected_results_broken_files: 0;
    in-out property <int> selected_results_broken_files2: 0;
    in-out property <int> selected_results_invalid_symlinks: 0;
    in-out property <int> selected_results_invalid_symlinks2: 0;
    in-out property <int> selected_results_empty_folders: 0;
    in-out property <int> selected_results_empty_folders2: 0;
    in-out property <int> selected_results_empty_files: 0;
    in-out property <int> selected_results_empty_files2: 0;
    in-out property <int> selected_results_temporary_files: 0;
    in-out property <int> selected_results_temporary_files2: 0;
    in-out property <int> selected_results_bad_extensions: 0;
    in-out property <int> selected_results_bad_extensions2: 0;
}
